<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
    <title>输入提示后查询</title>
    <link rel="stylesheet" href="https://cache.amap.com/lbs/static/main.css"/>
    <script type="text/javascript"
            src="https://webapi.amap.com/maps?v=1.4.15&key=3f74919d6c3b533ccc9c704ff86425c4"></script>
    <style type="text/css">
        body {
            font-size: 12px;
        }
        #tip {
            background-color: #ddf;
            color: #333;
            border: 1px solid silver;
            box-shadow: 3px 4px 3px 0px silver;
            position: absolute;
            top: 10px;
            right: 10px;
            border-radius: 5px;
            overflow: hidden;
            line-height: 20px;
        }
        #tip input[type="text"] {
            height: 25px;
            border: 0;
            padding-left: 5px;
            width: 280px;
            border-radius: 3px;
            outline: none;
        }
        #mapContainer {
            width: 100%;
            height: 100%;
        }

    </style>
</head>
<body>
<div id="mapContainer"></div>
<div id="tip">
    <input type="text" id="keyword" name="keyword" placeholder="请输入关键字查询" onfocus='this.value="${(keyword)!}"'/>
</div>
<script type="text/javascript">
    var windowsArr = [];
    var marker = [];
    var map = new AMap.Map("mapContainer", {
        resizeEnable: true,
      //  center: [116.397428, 39.90923],//地图中心点
        zoom: 13,//地图显示的缩放级别
        keyboardEnable: false
    });
    AMap.plugin(['AMap.ToolBar','AMap.Autocomplete','AMap.PlaceSearch'],function(){
        var toolbar = new AMap.ToolBar();
        map.addControl(toolbar);

        var autoOptions = {
            city: "广州", //城市，默认全国
            input: "keyword"//使用联想输入的input的id

        };
        autocomplete= new AMap.Autocomplete(autoOptions);
        var placeSearch = new AMap.PlaceSearch({
            city:'广州',
            map:map
        })
        AMap.event.addListener(autocomplete, "select", function(e){
            //TODO 针对选中的poi实现自己的功能
            placeSearch.setCity(e.poi.adcode);
            placeSearch.search(e.poi.name)
        });
    });
</script>
<script type="text/javascript" src="https://webapi.amap.com/demos/js/liteToolbar.js"></script>
</body>
</html>